Skip to content

Track kimi background subagents and keep the stall sweep off them (#175) - #1572

Merged
currentbits merged 2 commits into
mainfrom
fix/kimi-background-subagents-175
Oct 10, 2026
Merged

currentbits merged 2 commits into
mainfrom
fix/kimi-background-subagents-175

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #175.

What kimi actually does (read from the installed 0.39.1 CLI source)

kimi -p defaults to the steer print policy (applyPrintBackgroundPolicy). After the main turn, the process stays alive while Agent(run_in_background=true) tasks are pending. Each completion steers a new main turn on the same stream-json output. Stream-json never emits a completion or notification event. It only emits assistant, tool and tool-result lines, and progress text goes to stderr. Process exit is the only settle signal.

Root cause of "killed at settle"

While background agents run, the stream is silent. After 10 minutes checkStalls posted "No output from the kimi CLI… may be hung. Stop and retry". Stopping killed the agents and lost their results.

Changes

  • electron/kimi.js: Agent tool calls carry subagent: { description, agentType, background }, parsed from the args before truncation.
  • electron/runner-provider-kimi.js: each Agent call becomes a subagent row in the Agents panel.
  • electron/runner-watchdogs.js: checkStalls skips threads with a running subagent. This applies to all providers.
  • Tests: a fake kimi background-agent scenario (ack, silence, steered text, exit), covering rows, stall exemption, settle at exit, and stop → failed.

Limits

  • Several background agents all show running until the last one finishes, because only exit is observable.
  • AgentSwarm launches are not tracked.
  • Steered-turn text glues onto the previous assistant message. That is existing kimi text-merge behavior and is not changed here.
  • Not verified against a live kimi run: the local kimi login is expired.

🤖 Generated with Claude Code

kimi >= 0.24.2 keeps `kimi -p` alive while Agent(run_in_background)
tasks run (default "steer" print policy) but stream-json emits no
completion event. Kimi Agent calls now become subagent rows: foreground
rows settle on their tool result, background rows stay running until
the CLI exits (done on exit 0, failed on a crash; stop already fails
them). checkStalls skips threads with running subagents, so the
"may be hung, Stop" notice no longer baits users into killing the run
and losing the results.

Closes #175

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T07:57:02.321981Z 082efd3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 082efd37a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (thread.stalledAt) continue;
// Background subagents run silently in the parent CLI (kimi -p stays
// alive for them, #175); "may be hung, Stop" would kill their results.
if (hasRunningSubagent(thread.id)) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit the stall exemption to live background agents

After a crash or force-quit during a subagent, recoverInterruptedRuns marks the thread failed but leaves its persisted subagents rows as running, and startRun does not clear them. When that thread is run again, this unconditional check therefore suppresses stall detection for every subsequent turn even though the recorded subagent has no live process and can never settle. Settle stale rows during recovery or require this exemption to correspond to a currently active background agent.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit ef75c60 into main Oct 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kimi background subagents unsupported: turns killed at settle or silently stall

1 participant